/* Menu */
$(document).ready(function($) {	
	//menu horizontal
	ddsmoothmenu.init({
	mainmenuid: "wd-horizontal", 
	orientation: 'h', 
	classname: 'wd-menu', 
	contentsource: "markup"
	})
	//menu dropdown responsive
	$('a.wd-button-nav').click(function(){
		$('ul.wd-nav-sub-vertical').slideToggle();
		return false;
	});
	$( '.wd-nav-vertical ul.wd-nav-sub-vertical li.arrow-down > ul' )
		.hide()
		.click(function( e ){
			e.stopPropagation();
	});
	$('a.wd-button-nav').bind('click',function(e){
			e.stopPropagation();
			$(document).bind('click',function(){$('.wd-nav-vertical ul.wd-nav-sub-vertical').slideUp(500);});
		});
	$('.wd-nav-vertical ul.wd-nav-sub-vertical > li.arrow-down').toggle(function(){
	  $(this).find('ul').slideDown(500);
	}, function(){
	$(this).find('ul').slideUp(500);
	});
	
	/* Flexslider */
	$('.flexslider').flexslider({
		animation: "fade",
		start: function(slider){
		  $('body').removeClass('loading');
		}
	 });
	
	  //external
    $('a[rel="external"]').attr('target', '_blank');
	//select
	$('.wd-langue,.wd-web,.wd-select-Internal').msDropdown({roundedBorder:false});
	// menu device
    var pull = $('a.wd-pull');
    	menuDevice = $('.wd-nav-device ul.wd-drop-parent');
    	pull.on('click',function(e){
    	e.preventDefault();
    	menuDevice.slideToggle();
    });
    $('a.wd-pull').bind('click',function(e){
		e.stopPropagation();
		$(document).bind('click',function(){$('.wd-nav-device ul.wd-drop-parent').slideUp(500);});
	});
	$('ul.wd-drop-parent > li > ul').hide().click(function(e){
		e.stopPropagation();
	});
	$('ul.wd-drop-parent > li').toggle(
		function(){
			$(this).addClass('current');
			$(this).find('.wd-drop-children').slideDown("slow");
			
		}
		,function(){
			$(this).removeClass('current');
			$(this).find('.wd-drop-children').slideUp("slow");
	});
	
	$('#slider').flexslider({
		animation: "slide",
		controlNav: true,
    	directionNav: false,
		animationLoop: false,
		slideshow: false
	});
});


    // remove span page contact khoahna
    var href_main= document.location.href;
    if(href_main.indexOf('/lien-he-phong') != -1){
         $('.wd-main-content').removeClass("span8");
        $('.wd-main-content').addClass("span12");
    }
    if(href_main.indexOf('/') != -1){
        $('#wd-horizontal li:nth-child(1) a').addClass("selected");
          $('.wd-nav-sub-vertical li:nth-child(1) a').addClass("selected");
     
    }
    if(href_main.indexOf('/gioi-thieu-phong') != -1){
        $('#wd-horizontal li:nth-child(2) a').addClass("selected");
        $('#wd-horizontal li:nth-child(1) a').removeClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(2) a').addClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(1) a').removeClass("selected");
    }
    if(href_main.indexOf('/quy-che-quy-dinh-phong') != -1){
        $('#wd-horizontal li:nth-child(3) a').addClass("selected");
        $('#wd-horizontal li:nth-child(1) a').removeClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(3) a').addClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(1) a').removeClass("selected");
    }
    if(href_main.indexOf('/tai-lieu-bieu-mau-phong') != -1){
        $('#wd-horizontal li:nth-child(4) a').addClass("selected");
        $('#wd-horizontal li:nth-child(1) a').removeClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(4) a').addClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(1) a').removeClass("selected");
    }  
    if(href_main.indexOf('/thong-tin-thong-bao-phong') != -1){
        $('#wd-horizontal li:nth-child(5) a').addClass("selected");
        $('#wd-horizontal li:nth-child(1) a').removeClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(5) a').addClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(1) a').removeClass("selected"); 
    }           
    if(href_main.indexOf('/lien-he-phong') != -1){
        $('#wd-horizontal li:nth-child(6) a').addClass("selected");
        $('#wd-horizontal li:nth-child(1) a').removeClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(6) a').addClass("selected");
        $('.wd-nav-sub-vertical li:nth-child(1) a').removeClass("selected");
    }   
$(".wd-section-gallery li a[rel=img-group]").fancybox({
		'transitionIn'		:'none',
		'transitionOut'		:'none',
		'titlePosition' 	:'over',
		'titleFormat'		:function(title, currentArray, currentIndex, currentOpts){
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? '  ' + title :'') + '</span>';
		}
	});
	
	
	
	/* $(document).ready(function(){
	var cookieName = 'theme';
	var cookieOptions ={path:'/', expires:3};
	if ($.cookie(cookieName) == null){
		$.cookie(cookieName, 1, cookieOptions);
	}
	$('#wd-theme-switcher').addClass('wd-theme' + $.cookie(cookieName));
	$('#wd-switcher > li').eq($.cookie(cookieName) - 1).addClass('wd-current');
	var totalTheme = $('#wd-switcher > li').length;
	$('#wd-switcher').find('a').each(function(e){
		$(this).click(function(){
			$.cookie(cookieName, $(this).attr('rel'), cookieOptions);
			$('#wd-switcher > li').removeClass('wd-current').eq($.cookie(cookieName) - 1).addClass('wd-current');
			for (var i=1;i<=totalTheme;i++ ){
				$('#wd-theme-switcher').removeClass('wd-theme' + i);
			}
			$('#wd-theme-switcher').addClass('wd-theme' + $.cookie(cookieName));
			return false;
		});
	});
}); */
	
	
